from django.contrib import admin
from .models import Deck, DeckCard


class DeckCardInline(admin.TabularInline):
    model = DeckCard
    extra = 0


@admin.register(Deck)
class DeckAdmin(admin.ModelAdmin):
    """卡组管理"""
    list_display = ('name', 'user', 'total_cards', 'is_active', 'created_at')
    list_filter = ('is_active', 'created_at')
    search_fields = ('name', 'user__username', 'user__nickname')
    ordering = ('-created_at',)
    inlines = [DeckCardInline]


@admin.register(DeckCard)
class DeckCardAdmin(admin.ModelAdmin):
    """卡组卡牌管理"""
    list_display = ('deck', 'card', 'quantity')
    list_filter = ('card__rarity',)
    search_fields = ('deck__name', 'card__name')
